<?php

namespace App\Http\Requests\OperationManagement;

use Illuminate\Foundation\Http\FormRequest;
use App\Http\Requests\BaseRequest;

class SanitationSiteRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'category_id' => 'required|integer',
            'address' => 'required',
            // 'organization_id' => 'required|integer',
            'principal_id' => 'required|integer',
            'phone' => 'required|regex:/^1[345789][0-9]{9}$/',
            // 'run_time' => 'required'
        ];
    }

    public function messages() 
    {
        return [
            'name.required' => '站点名称不能为空',
            'category_id.required' => '站点类型不能为空',
            'category_id.integer' => '站点类型只能填写数字',
            'address.required' => '地址不能为空',
            'organization_id.required' => '所属公司不能为空',
            'organization_id.integer' => '所属公司只能填写数字',
            'principal_id.required' => '负责人不能为空',
            'principal_id.integer' => '负责人只能填写数字',
            'phone.required' => '手机号不能为空',
            'phone.regex' => '手机号格式不合法',
            'run_time.required' => '运营时间不能为空'
        ];
    }

}
